package br.com.informatos.notifications;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Button btn_Notification = (Button)findViewById(R.id.btn_notificaion);

		btn_Notification.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MainActivity.this, NotificationActivity.class);
				PendingIntent pedingIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);


				Notification notification = new NotificationCompat.Builder(MainActivity.this)				
				.setContentTitle(getString(R.string.new_notification))
				.setContentText(getString(R.string.notification_content))
				.setSmallIcon(R.drawable.ic_launcher)
				.setAutoCancel(true)
				.setContentIntent(pedingIntent)
				.build();

				NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
				notificationManager.notify(0,notification);

			}
		});		

	}

}
